﻿using Newtonsoft.Json;

namespace Hpt.Device.Sample.Dto;

public class TradeGetResponse : DeviceResponseBaseV1
{
    [JsonIgnore]
    public int Index { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, Order = 2)]
    public string Number => Index.ToString();

    [JsonIgnore]
    public DateTime? TransactionTime { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, Order = 3)]
    public string Time => TransactionTime.HasValue ? TransactionTime.Value.ToString("yyyyMMddHHmmss") : "";

    [JsonIgnore]
    public string UserName { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, Order = 4)]
    public string Name => UserName ?? "";

    [JsonProperty(NullValueHandling = NullValueHandling.Include, Order = 5)]
    public string Consume => $"{TransactionAmount:F2}{(TransactionWallet == WalletTypes.Timers ? "次" : "元")}";

    [JsonIgnore]
    public decimal TransactionAmount { get; set; }

    [JsonProperty(NullValueHandling = NullValueHandling.Include, Order = 6)]
    public string Class => IsConsumption
        ? Increase ? "退款" : "消费"
        : Increase ? "充值" : "退还";

    [JsonIgnore]
    public WalletTypes TransactionWallet { get; set; }

    [JsonIgnore]
    public bool IsConsumption { get; set; }

    [JsonIgnore]
    public bool Increase { get; set; }
}